@include('layouts.user_header')
<script type="text/javascript" charset="utf-8" src="{{asset('wangEditor-3.0.4/release/wangEditor.js')}}"></script>

<div class="main layui-clear">
  <div class="fly-panel" pad20>
    <h2 class="page-title">发表问题</h2>
    
    <!-- <div class="fly-none">并无权限</div> -->

    <div class="layui-form layui-form-pane" lay-filter="tags">
      <form class="form form-horizontal"  onclick="re_content()"  action="{{url('article/add/submit')}}" method="post">
        <input type="hidden" value="{{csrf_token() }}" name="_token" />
        <div class="layui-form-item">
          <label for="L_title" class="layui-form-label">标题</label>
          <div class="layui-input-block">
            <input type="text" id="L_title" name="article_name" required lay-verify="required" autocomplete="off" class="layui-input">
          </div>
        </div>
        <div class="layui-form-item layui-form-text">
          <div class="layui-input-block">
            <textarea  class="real_content"  name="article_content" style="display:none"></textarea>
            <div id='editor_content' ></div>

          </div>
          <label for="L_content" class="layui-form-label" style="top: -2px;">描述</label>
        </div>
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">所在类别</label>
            <div class="layui-input-block">
              <select lay-verify="required" name="tags_id" class="tags_id">
                <option></option>
                @foreach($tags as $v)
                  <option value="{{$v->tags_id}}" section="{{$v->section_id}}" >{{$v->tags_name}}</option>
                @endforeach
              </select>
              <input class="section_id" name="section_id" value="1" type="hidden"/>
              <input class="tags_name" name="tags_name" value="0" type="hidden"/>
            </div>
          </div>
     {{--     <div class="layui-inline">
            <label class="layui-form-label">悬赏飞吻</label>
            <div class="layui-input-block">
              <select name="experience">
                <option value="5" selected>5</option>
                <option value="20">20</option>
                <option value="50">50</option>
                <option value="100">100</option>
              </select>
            </div>
          </div>--}}
        </div>
        <div class="layui-form-item">
          <label for="L_vercode" class="layui-form-label">人类验证</label>
          <div class="layui-input-inline">
            <input type="text" id="L_vercode" name="vercode" required lay-verify="required" placeholder="请回答后面的问题" autocomplete="off" class="layui-input">
          </div>
          <div class="layui-form-mid">
            <span style="color: #c00;">1+1=?</span>
          </div>
        </div>
        <div class="layui-form-item">
          <button class="layui-btn" lay-filter="*" lay-submit>立即发布</button>
        </div>
      </form>
    </div>
  </div>
</div>
<script>
    layui.use('form', function(){
        var form = layui.form();
        form.on('select', function(data){
            console.log(data.value);
            var section=$('select  [value='+data.value+']').attr('section');

            var tag_name=$('.layui-anim-upbit  [lay-value='+data.value+']').html();

            $('.section_id').val(section);
            $('.tags_name').val(tag_name);
        });
    });

    var E = window.wangEditor;
    var editor2 = new E('#editor_content');
    editor2.customConfig.uploadImgShowBase64 = true
    editor2.customConfig.uploadImgMaxLength = 1;
    editor2.create();
    function  re_content() {
        $('.real_content').val(editor2.txt.html());
    }

</script>
@include('layouts.user_footer')
